/**
 * 枚举，先用文件保存字典
 */
const defaultConfig =  {
    config: {
      inline: true
    },
    items: [
      { label: '类型名称', prop: 'tpName', size: 'small' },
      { label: '类型编号', prop: 'tpId', type: 'number' },
      {
        label: '性别',
        prop: 'sex',
        type: 'radio',
        style: { width: '150px' },
        options: [
          { label: '男', value: 'man' },
          { label: '女', value: 'woman' }
        ]
      },
      {
        label: '爱好',
        prop: 'loves',
        type: 'checkbox',
        options: [
          { label: '摄影', value: 'sheying' },
          { label: '电影', value: 'dianying' }
        ]
      }
    ],
    
    buttons: [
      {
        text: '确定',
        emitName: 'confirm',
        type: 'primary',
        handler: 'funcRef: searchByForm'
      },
      {
        text: '取消',
        emitName: 'cancle',
        handler: `funcRef: resetForm`
      }
    ]
  }
module.exports = function({ fields=[] }, result){
    const columns = fields.filter(({query})=>query).map(({query:{search,dictRef,dateType,type='input'},label,prop})=>{
        const item =  {
            type,
            label,
            prop,
            dateType,
            search
        }
        if(type==='datePicker'){
          item.format = 'YYYY-MM-DD'
          item['value-format']='YYYY-MM-DD'
        }
        if(dictRef){    
            item.options = "dictRef: "+dictRef
        }
        if(type==='select'){
            item. style= { width: '150px' }
        }
        if(search){
            item.search = search
        }
        return item
    })
    result.queryForm = defaultConfig
    result.queryForm.items = columns
}